inspector: Limit the width of readonly properties
authorMatthias Clasen <mclasen@redhat.com>
Tue, 17 Nov 2020 18:33:59 +0000 (13:33 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 17 Nov 2020 18:36:57 +0000 (13:36 -0500)
For readonly properties, we show the serialized value
in a label. If we don't take precautions, this can cause
our window to grow extremely wide, and break things.
So, ellipsize things at a reasonable size.

Fixes: #3278
gtk/inspector/prop-editor.c

index dc2f6f2648033d50e1b6b61b709c4cf7c720f979..019d34ffbe41fa5d82f840d50eb76afc3a47ce08 100644 (file)
@@ -1551,6 +1551,11 @@ constructed (GObject *object)
   if (!can_modify)
     {
       label = gtk_label_new ("");
+      gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
+      gtk_label_set_max_width_chars (GTK_LABEL (label), 20);
+      gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+      gtk_widget_set_hexpand (label, TRUE);
+      gtk_widget_set_halign (label, GTK_ALIGN_FILL);
       gtk_widget_add_css_class (label, "dim-label");
       gtk_box_append (GTK_BOX (box), label);